package kr.saeildamil.androidstudy.ch19;

import kr.saeildamil.androidstudy.R;
import android.R.integer;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class AsyncTaskBasic extends Activity {
	TextView tv;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch19_asynctaskbasic);
				
		tv = (TextView)findViewById(R.id.ch19_asynctaskbasic_tv);
	}
	
	public void mOnClick(View v){
		new AsyncTaskTest().execute(100);
	}
	class AsyncTaskTest extends AsyncTask<Integer, Integer, Integer>{
		
		@Override
		protected void onPreExecute() {
			Log.d("AsyncTask","onPreEXecute()");
			super.onPreExecute();
		}
		
		@Override
		protected Integer doInBackground(Integer... params) {
			Log.d("AsyncTask","doInBackGround Params" + params[0]);
			int i;
			for(i = 0; i<10; i++)
				publishProgress(i);
			return i;
		}
		
		@Override
		protected void onProgressUpdate(Integer... values) {
		
			super.onProgressUpdate(values);
		}
		
		

		@Override
		protected void onCancelled() {
		
			super.onCancelled();
		}

		@Override
		protected void onPostExecute(Integer result) {
		
			super.onPostExecute(result);
		}

		

		
		
	}
}
